package Servlets;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import util.conexion;
 
 
@WebServlet("/ServletEliminarOferta")
public class ServletEliminarOferta extends HttpServlet {
	private static final long serialVersionUID = 1L;
     
    public ServletEliminarOferta() {
        super();
        
    }
 
	 
	 
	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		 Integer codigo = Integer.parseInt(req.getParameter("txtcodigo"));
		 try {
			Connection cn = conexion.obtenerConexion();
			String sql = "Delete from ofertas where idOfertas=?";
			PreparedStatement pst = cn.prepareStatement(sql);
			pst.setInt(1, codigo);
			pst.executeUpdate();
			RequestDispatcher rd = req.getRequestDispatcher("/listando");
			rd.forward(req, res);
					
		} catch (Exception e) {
			 e.printStackTrace();
		}
		
		
	}
	}

 
